#include <GL/glut.h>
#include <math.h>

const GLfloat Pi = 3.1415926536f;

void myDisplay(void) {
	GLfloat a = 1/(2-2*cos(72*Pi/180));
	GLfloat bx = a * cos(18*Pi/180);
	GLfloat by = a * sin(18*Pi/180);
	GLfloat cy = -a * cos(18*Pi/180);
	GLfloat PointA[2] = {0, a};
	GLfloat PointB[2] = {bx, by};
	GLfloat PointC[2] = {0.5, cy};
	GLfloat PointD[2] = {-0.5, cy};
	GLfloat Ponit[2] = {-bx, by};

	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_LINE_LOOP);
		glVertex2fv(PointA);
		glVertex2fv(PointC);
		// glVertex2fv(PointE); // @TODO
		glVertex2f(-bx, by);
		glVertex2fv(PointB);
		glVertex2fv(PointD);
	glEnd();
	glFlush();
}

int main(int argc, char * argv[]) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
	glutInitWindowPosition(500, 500);
	glutInitWindowSize(500, 500);
	glutCreateWindow("OpenGL Program 4: 五角星");

	glutDisplayFunc(myDisplay);

	glutMainLoop();

	return 0;
}
